<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="org.hibernate.SessionFactory"%>
<%@ page import="org.hibernate.Session"%>
<%@ page import="java.util.List"%>
<%@ page import="hibernate.model.*"%>
<%@ page import="hibernate.util.HibernateUtil"%>
<%@ page import="hibernate.method.*"%>
<%@ page import="hibernate.method.UserMethods"%>
<link rel="stylesheet" href="css/sidebar.css">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"> </script>
<style type="text/css">
.templatemo_form input {
	height: 20px;
}
</style>
<div id="games">

<div class="page-header">
	<h2 class="page-title">Nowa gra</h2>
</div>
<%
						//String type = "client";
						SessionFactory sessionFactory = HibernateUtil
								.getSessionAnnotationFactory();
						Session s = sessionFactory.openSession();
						s.beginTransaction();
						CategoryMethods catm = new CategoryMethods();
						GameCategoryMethods gcatm= new GameCategoryMethods();
						List <Category> catlist = catm.listAllCategories(sessionFactory, s);
						
					%> 

<br />

<div id="content">


 
	<form role="form" style="position: block; top: -40px;" id='addGame' enctype="multipart/form-data"
		action="../AddGame" method="post">

		<table>
			<tr>
				<td>Nazwa gry:</td>
				<td>
						<input type="text" id="name" name="name"
							class="form-control" required
							placeholder="Wpisz nazwe gry" maxlength="80"
							autocomplete="off">
					
				</td>
			</tr>
	
			<tr>
				<td>Minimalna ilosc osób:</td>
				<td>
						<input type="number" id="users_min" name="users_min"
							class="form-control" required value ="1"
							 maxlength="80">
					
				</td>

			</tr>
			
				<tr>
				<td>Maksymalna ilosc osób:</td>
				<td>
						<input type="number" id="users_max" name="users_max"
							class="form-control" required value="7"
							 maxlength="80">
					
				</td>

			</tr>
			
			<tr>
			<td>
			Opis gry
			</td>
			<td>
						<input type="text" id="opis" name="opis"
							class="form-control" required
							placeholder="Wpisz opis gry" maxlength="80"
							autocomplete="off">
			</td>
			</tr>
			<tr>
			<td>
			
			Kategorie:
			</td>
			<td>
			<%
						List <Category> cat = catm.listAllCategories(sessionFactory, s);
							if (cat.size() > 0) {
							for (Category c : cat) {
								String catname = c.getCategory();
								int id = c.getCategory_id();%>
								
						<input type="checkbox" name="categories" value="<%=id%>"/><%=catname%> <br>
						<%}
							
						}
						if (cat.size() == 0) {
					 out.println("Nie ma zadnych kategorii w bazie");
					
						} %>
						</td>
						</tr>
							<tr>
					<td>Avatar: </td>
					<td><input type="file" name="avatar" id="avatar" size="50"/></td>
				</tr>
		
			<tr>
				<td><input type="submit" class="mainBtn" value="Dodaj grę" /></td>
			</tr>
		</table>
		
	</form>

	</div>
	</div>